<template>
	<view class="page_home">
		<u-navbar title="首页" bgColor='#f56e3d' placeholder fixed safeAreaInsetTop :titleStyle="{color: '#fff'}"
			id="navbar">
			<view class="u-nav-slot" slot="left" style="display: flex; width: 300rpx; " @click="gotoSearch">
				<u-search :placeholder="pageParams.keyWords ? pageParams.keyWords :'搜索'" :showAction="false"
					shape="round" @click="gotoSearch" readonly></u-search>
			</view>
			<view class="u-nav-slot" slot="right" @click="gotoCollect">
				<u-icon size="30" name="star" color="#fff"></u-icon>
			</view>
			<view class="u-nav-slot" slot="right" @click="publishEject">
				<u-icon size="30" name="home" color="#fff" id="handleEdit"></u-icon>
			</view>
			<view class="u-nav-slot" slot="right" @click="mapHouse">
				<u-icon size="30" name="map" color="#fff"></u-icon>
			</view>
		</u-navbar>
		<!-- <view class="" v-if="!showNavState" style="width: 100%; height: 44px;">暂无图片</view> -->
		<!-- 	<view class="banner_box">
			<video src="https://dabinhouse-1320826375.cos.ap-shanghai.myqcloud.com/down/203449-921267347_large.mp4" poster-for-crawler=""></video>
		</view> -->
		<view class="banner_box">
			<videoSwiper :loading="loadingSwiper" :circular="false" :list="imgList" keyName="bannerUrl" interval="5000"
				height="200" @click="clickVideo" @playVideo="playVideo"></videoSwiper>
		</view>
		<!-- -->
		<view @click="congratulations" >   
		    <u-notice-bar :text="'恭喜'+ data.brokerName+'签单成功！成交'+data.actualCashflow+'元,收获'+ data.achievMoney+'业绩！' +'进取又积极，仿佛神来之笔！'"   direction="row" speed="80" ></u-notice-bar>
		  </view>
			<image src="../../static/default/banner1.jpeg" style="width: 100%; height:225rpx;"></image>
		<view class="tabs_view">
			<u-tabs :list="tabsList" @click="tabclick" lineColor="rgb(240, 90, 35)" :current="currentIndex"
				itemStyle="padding:0 32.5px; height: 34px;" :activeStyle="{
					color: '#303133',
					fontWeight: 'bold',
					transform: 'scale(1)'
		}"></u-tabs>
		</view>
		<view class="wrapper">
			<view class="list_wrapper">

				<view class="u-page">

					<view v-show="pageList.length != 0">
						<checkbox-group v-model="checkedList">
							<view class="list_item" v-for="(item, index) in pageList" :key="index">
								<ListItem :info="item" @click.native="gotoDetails(item)" @onShare="changeOnShare">
									<template slot="topRight">
										<checkbox color="rgb(240, 90, 35)" v-if="showShare"
											@click.stop="changeChecked(item.id, item.mediaUrl)"></checkbox>
									</template>
								</ListItem>
							</view>
						</checkbox-group>
					</view>
					<view class="" v-show="pageList.length == 0">
						<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
						</u-empty>
					</view>
				</view>
			</view>
		</view>
		<u-loadmore :status="status" v-if="pageList.length != 0" />
		<!-- 其他 -->
		<view class="fliter_state">
			<u-popup :show="otherRent" :round="10" mode="right" @close="otherRent = false; currentIndex = 0"
				closeIconPos="top-right" closeable closeOnClickOverlay :safeAreaInsetTop="true" safeAreaInsetBottom>
				<view class="rent_wrapper">
					<view class="lable_title">
						出租方式
					</view>
					<view class="content">
						<view class="tag_wrp">
							<view class="item" v-for="(item, index) in lodgeType" :key="index">
								<view :class="['label', otherInfo.lodgeData === item.id ? 'activ_change_color' : ''  ]"
									@click="otherInfo.lodgeData === item.id ? otherInfo.lodgeData = null : otherInfo.lodgeData = item.id">
									{{ item.name }}
								</view>
							</view>
						</view>
					</view>
					<view class="lable_title">
						户型
					</view>
					<view class="content">
						<view class="tag_wrp">

							<view class="item" v-for="(item, index) in houseType" :key="index">
								<view :class="['label', otherInfo.typeData === item ? 'activ_change_color' : ''  ]"
									@click="otherInfo.typeData === item ? otherInfo.typeData = null : otherInfo.typeData = item">
									{{ item}}
								</view>
							</view>
						</view>
					</view>

					<view class="lable_title">
						房间特色
					</view>
					<scroll-view class="content" scroll-y>
						<view class="tag_wrp">
							<view class="item" v-for="(item, index) in houseSpecial" :key="index">
								<view
									:class="['label', otherInfo.specialData.includes(item.labelName) ? 'activ_change_color' : ''  ]"
									@click="specialTagClick(item.labelName)">
									{{ item.labelName}}
								</view>
							</view>
						</view>
					</scroll-view>

					<view class="lable_title">
						出租状态
					</view>
					<view class="content">
						<view class="tag_wrp">

							<view class="item" v-for="(item, index) in houseStatus" :key="index">
								<view :class="['label', otherInfo.statusData === item.id ? 'activ_change_color' : ''  ]"
									@click="otherInfo.statusData === item.id ? otherInfo.statusData = null : otherInfo.statusData = item.id">
									{{ item.name }}
								</view>
							</view>
						</view>
					</view>
					<view class="lable_title">
						其他
					</view>
					<view class="content">
						<view class="tag_wrp">
							<view class="item" v-for="(item, index) in otherStatus" :key="index">
								<view :class="['label', otherInfo.otherData === item.id ? 'activ_change_color' : ''  ]"
									@click="otherInfo.otherData === item.id ? otherInfo.otherData = null : otherInfo.otherData = item.id">
									{{ item.name }}
								</view>
							</view>
						</view>
					</view>
					<view class="btn_wrp">
						<view class="btn">
							<u-button ripple @click="otherReset">重置</u-button>
						</view>
						<view class="btn">
							<u-button color="rgb(240, 90, 35)" ripple @click="otherSubmit">确定</u-button>
						</view>
					</view>
				</view>
			</u-popup>
		</view>
		<!-- 搜索 -->
		<view class="show_rent_box_view">
			<u-popup :show="showSearch" :round="10" mode="bottom" @close="cloneMoney" closeable closeOnClickOverlay
				safeAreaInsetTop safeAreaInsetBottom>
				<searchFilter @search='changeSearch($event)' @result="resultSerch" ref="rentResult"></searchFilter>
			</u-popup>
		</view>
		<!-- 租金 -->
		<view class="show_rent_box_view">
			<u-popup :show="showRent" :round="10" mode="bottom" @close="cloneMoney" closeable closeOnClickOverlay
				safeAreaInsetTop safeAreaInsetBottom>
				<rentFilter @change='changeRent($event)' ref="rentResult" @result="resultValue"></rentFilter>
			</u-popup>
		</view>

		<u-overlay :show="eject" @click="eject = false" opacity="0" @touchmove.stop.prevent="disabledScroll">
			<view class="eject" :style="{top: 70 + 'px', right:30+ 'px'}">
				<div class="triangle-up"></div>
				<u-icon label="发布房源  " size="20" style="margin-bottom: 10rpx;" color="#fff" labelColor="#fff"
					name="plus-people-fill" @click="publish"></u-icon>
				<u-line color="#ffffff"></u-line>
				<u-icon label="我发布的房源" size="20" style="margin: 10rpx 0; margin-top: 20rpx;" color="#fff"
					labelColor="#fff" name="../../static/operate/icon.png" @click="myPublish"></u-icon>
			</view>
		</u-overlay>
		<u-toast ref="uToast"></u-toast>
		<u-popup :show="isSearchViewIsShow" :round="10" mode="center" @close="isSearchViewIsShow = false">
			<scroll-view scroll-y="true" style="height: 100vh; width: 100vw; background-color: #fff;">
				<searchPage @click="tounchNameMethod" @result="resultSerch" @backPage="isSearchViewIsShow = false; "
					:searchValue="pageParams.keyWords"></searchPage>
			</scroll-view>
		</u-popup>

		<u-popup catchtouchmove="true" :show="showTips" mode="center" :round="10" overlayOpacity="0.3"
			:customStyle="{backgroundColor: '#a6c6f7'}">
			<view class="popup_box" v-if="completeInfoState== '0'">
				<view class="title">
					欢迎您,经纪人!
				</view>
				<view class="prompt">
					您需要完善资料信息，以便能</br>
					够更好的为您提供服务。
				</view>
				<view class="button_box">
					<u-button type="primary" class="sure" @click="toPerfectInfo">完善资料</u-button>

				</view>
			</view>
			<view class="popup_box" v-if="completeInfoState == '1'">
				<view class="title">
					欢迎您,经纪人!
				</view>
				<view class="prompt">
					您的房东信息我们正在加速</br>审核中......
				</view>
			</view>
		</u-popup>
		<u-popup catchtouchmove="true" :show="showShare" :closeable="true" :overlay="false" mode="bottom"
			:closeOnClickOverlay="false" :customStyle="{borderTop:'1rpx solid #dadada'}" @close="closeShare">
			<view class="padding">
				<u-checkbox-group v-model="checkboxValue1" placement="row" @change="checkboxChange1">
					<u-checkbox shape="circle" :customStyle="{marginBottom: '20px',marginRight: '20px'}"
						v-for="(item, index) in checkboxList" :key="index" :label="item.label" :name="item.name">
					</u-checkbox>
				</u-checkbox-group>
				<!-- <u--text :text="text"></u--text> -->
				<view class="text_row">
					<view style="width: 60%;">
						已选<text>{{checkedList.length || 0}}</text>套房源
					</view>
					<u-button color="#f05a23" text="分享到好友" style="width: 40%;" @click="shareInfo('WXSceneSession')"
						size="normal"></u-button>
					<u-button color="#3c9cff" text="分享到朋友圈" style="width: 40%; margin-left: 10%;"
						@click="shareInfo('WXSceneTimeline')" size="normal"></u-button>
				</view>
			</view>
		</u-popup>
		<u-popup catchtouchmove="true" :show="showQrTips" mode="center" :overlay="true" :round="10" :closeable="true"
			:closeOnClickOverlay="true" @close="closeQrCode">
			<view style="width: 350px;height:380px;">
				<image :src="qrimgUrl" style="width: 310px;top:3%;height: 310px;left: 5%;"></image>
				<u-button type="warning" size="small" shape="circle"
					style="width: 50%;height: 35px;font-size: 20px;margin-top: 2%;" text="保存到相册"
					@click="saveImage"></u-button>
			</view>
		</u-popup>
		<u-overlay opacity="1" duration="0" :show="VideoShowLook" @click="showTababr">
			<view class="" style="	display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;">
				<video :src="videoSrc" style="width: 100%;" ref="video" @loadstart="loadeddata"
					:autoplay="true"></video>
			</view>
		</u-overlay>

		<u-modal :show="isShowLocation" title="位置权限" content='请开启位置权限 否则无法使用'></u-modal>
	</view>

</template>

<script>
	import {
		homeListPage,
		getImgList,
		getUserInfo,
		getServerAppVersion,
		getQrcode
	} from '@/api/home/index.js'
	import {
		getLables
	} from "@/api/index.js"
	import {
		survey,
		addMedia
	} from '@/api/survey/index.js'
	import {
		getLast
	} from '@/api/tidings/index.js'
	import ListItem from '../components/ListItem.vue';
	import rentFilter from "../components/rentFilter.vue";
	import searchFilter from "../components/searchFilter.vue";
	import searchPage from "./search.vue";
	import videoSwiper from "../../components/swiper/index.vue"
	const fUN_AmapLocation = uni.requireNativePlugin('FUN-AmapLocation');

	export default {
		data() {
			return {
				VideoShowLook: false,
				videoSrc: "",
				qrimgUrl: '',
				isChecked: false,
				isShowLocation: false,
				checkedList: [],
				data:{},
				editViewOption: {
					top: 0,
					right: 0
				},
				value: '',
				options: {
					useDynamicSize: false,
					errorCorrectLevel: 'Q',
					margin: 10,
					areaColor: "#fff",
					// 指定二维码前景，一般可在中间放logo
					foregroundImageSrc: require('../../static/default/qrlogo.png')
				},

				leftNum: 0,
				navbarTop: 75,
				showShare: false,
				loadingSwiper: true,
				showNavState: false,
				isSearchViewIsShow: false,
				currentIndex: 0,
				isTabsShow: false,
				imgList: [],
				btnStyle: {
					marginTop: '20px',
					color: '#fff',
					background: 'rgb(240, 90, 35)',
					height: '40px'
				},
				status: 'loading',
				showTips: false,
				showQrTips: false,
				eject: false,
				text: '勾选此项，租客查看图片后，7天内在您可签约的范围里，该客从大宾租房平台再来，客源优先给您~',
				checkboxValue1: [],
				checkboxList: [{
						label: '显示小区',
						name: 'community',
					},
					{
						label: '显示租金',
						name: 'rent',
					}
				],
				completeInfoState: null,
				pageList: [],
				pageParams: {
					pageNum: 1,
					pageSize: 10,
					orderByColumn: null,
					buildingNumber: null,
					keyWords: this.$store.state.searchForm.communityName, //关键字 包含了小区名称 
					rentalBegin: null, // 起始租金
					rentalEnd: null, // 止租金
					isAsc: null,
					rentalType: null, // 出租类型 0 合租 1 整租 
					houseType: null, // 几室直接传资
					houseLabels: [],
					rentState: null,
					ventricleNumber: null, //房间号
					// 描述：排序规则desc 升序，asc 降序
				},
				tabsList: [{
					name: '搜索',
				}, {
					name: '租金',

				}, {
					name: '其他',

				}, {
					name: '多选',

				}],
				//搜索
				showSearch: false,
				// 租金
				showRent: false,
				// 其他
				otherRent: false,
				lodgeType: JSON.parse(uni.getStorageSync('houseFilter')).lodgeType,
				houseType: JSON.parse(uni.getStorageSync('houseFilter')).houseType,
				houseSpecial: [],
				houseStatus: JSON.parse(uni.getStorageSync('houseFilter')).houseStatus,
				otherStatus: JSON.parse(uni.getStorageSync('houseFilter')).otherStatus,
				otherInfo: {
					lodgeData: "",
					typeData: "",
					specialData: [],
					statusData: "",
					otherData: ""
				},
				fliterChecked: [],
				longitude: "",
				latitude: "",
				timeLOcation: null,
				flagState: uni.getStorageSync('flagState') || '100'
			}
		},

		components: {
			ListItem,
			searchFilter,
			rentFilter,
			searchPage,
			videoSwiper
		},
		onLoad(option) {
			var that = this
			// console.log(that.$store.state.flagState);
			console.log(fUN_AmapLocation, 'fUN_AmapLocation');
			that.getAndroidState()

			// );
			if (option.name) {
				console.log(option);
			}
			// that.startTimeGet()
			that.loadmore();
			that.getSwriper();
			that.clearVUEX();
			that.showNavState = true;

		},
		mounted() {
			this.editViewOption.top = '100rpx'
			this.editViewOption.right = "100rpx"


		},
		onShow() {
			var that = this
			that.queryVersion();
			that.ifFunState();
			that.getNewTags();
			that.getLast()

		},
		onPullDownRefresh() {
			this.status = 'loading';
			this.clearVUEX()
			this.ifFunState();
			this.getSwriper()
			this.checkedList = []; //下拉清空之前所选
			for (var key in this.pageParams) {
				this.pageParams[key] = null
			}
			this.pageParams.houseLabels = []
			this.pageParams.pageNum = 1;
			this.pageParams.pageSize = 10
			console.log(this.pageParams);

			this.pageList = [];
			this.loadmore();
			this.$refs.uToast.show({
				type: "success",
				message: '刷新成功',

			})
		},
		onReachBottom() {
			this.loadmore()
		},
		methods: {
		 congratulations() {
			 uni.navigateTo({
			 	url:'/pages/home/tidings/tidingsDetail'
				// url:'/pages/home/tidings/index'
			 })
		 },
			getLocationState() {
				 
				uni.getLocation({
					type: 'gcj02',
					altitude: true,
					success: (obj) => {
						
					},
					fail(err) {
						uni.showModal({
							title: '重要提示!',
							content: '为了提供更精准位置服务，您需要打开手机的定位功能且赋予App使用位置服务的权限！否则将无法正常使用App功能',
							showCancel: false,
							success: function(res) {
								if (res.confirm) {
									//plus.runtime.quit();
								}
							}
						});
						fUN_AmapLocation.stop({}, result => {

						});
					},

				});
			},
			isWithinTimeRange() {
				const currentDate = new Date();
				const currentHour = currentDate.getHours();
				if (currentHour >= 7 && currentHour <= 23) {
					return true;
				} else {
					return false;
				}
			},
			getAndroidState() {
				var that = this
				var state = that.$store.state.flagState
				if (that.$store.state.flagState) {
					uni.showToast({
						title: '为了提供精准位置服务，请关闭电池节能优化功能',
						icon: 'none',
						success() {
							if (that.$store.state.flagState) {
								fUN_AmapLocation.requestIgnoreBatteryOptimizations(function(result) {
									that.$store.commit('changeFlagState', "")
									that.getAndroidState()
								});
							}
						}
					})
				} else {
					fUN_AmapLocation.hasLocationPermissions(function(resultLocation) {
						if (!resultLocation.flag) {
							fUN_AmapLocation.requestLocationPermissions(function(result) {
								if (!result.flag) {
									uni.showModal({
										title: '重要提示!',
										content: '为了提供更精准位置服务，您需要打开手机的定位功能且赋予App使用位置服务的权限！否则将无法正常使用App功能',
										showCancel: false,
										success: function(res) {
											if (res.confirm) {
												plus.runtime.quit();
											}
										}
									});
								}
							});
						} else {
							if (that.isWithinTimeRange()) {
								fUN_AmapLocation.start({
										intervalTime: 300000, //300000
									},
									result1 => {
										that.insertAppLoaction()
									})
							}
						}
					});
				}
			},

			insertAppLoaction() {
			 
				var that = this;
				fUN_AmapLocation.hasLocationPermissions(function(resultLocation) {
					// console.log(resultLocation);
					if (!resultLocation.flag) {
						// uni.showModal({
						// 	title: '位置权限',
						// 	content: '请在设置里开启位置权限 否则无法使用',
						// 	showCancel: false,
						// 	success: function(res) {
						// 		if (res.confirm) {
						// 			plus.runtime.quit();
						// 		}
						// 	}
						// });

						fUN_AmapLocation.stop({}, result => {
							console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
						});
					} else {
						uni.getLocation({
							type: 'gcj02',
							altitude: true,
							success: (obj) => {

								that.longitude = obj.longitude;
								that.latitude = obj.latitude;
								let uid = uni.getStorageSync("uid")
								const token = uni.getStorageSync('token');
								const location = {
									"requestPath": 2,
									"longitude": that.longitude,
									"latitude": that.latitude,
									"userId": uid
								}
								survey.insertAppLoaction(location).then(res => {

								})
							},
							fail(err) {
								// console.log(err);
								uni.showModal({
									title: '重要提示!',
									content: '为了提供更精准位置服务，您需要打开手机的定位功能且赋予App使用位置服务的权限！否则将无法正常使用App功能',
									showCancel: false,
									success: function(res) {
										if (res.confirm) {
											//plus.runtime.quit();
										}
									}
								});
								fUN_AmapLocation.stop({}, result => {
									console.log('====fUN_AmapLocation定位stop====', JSON.stringify(
										result));
								});
							},

						});
					}
				})




			},
			showTababr() {
				var that = this
				uni.showTabBar({
					animation: true,
					success() {
						that.VideoShowLook = false;
					}
				})
			},
			loadeddata() {


			},
			playVideo(url) {
				// console.log(url);
				this.videoSrc = url.bannerVideoUrl;
				this.VideoShowLook = true;
				uni.hideTabBar({
					animation: true,
				})
			},
			clickVideo(e) {
				console.log(e);
			},
			// changeLogeData(key, item) {
			// 	console.log(this[key] == item);
			// 	if(this[key] == item) {
			// 		this[key] = null
			// 	}else {
			// 		this[key] = item
			// 	}
			// },

			async getNewTags() {
				const res = await getLables();
				this.houseSpecial = res.data.rows;
				this.$store.commit('changetagNames', res.data.rows)

			},
			mapHouse() {
				uni.navigateTo({
					url: './map/map'
				})
			},
			//分享id
			changeOnShare(id) {
				//弹出提示框
				this.showShare = !this.showShare
				//改变下标
				this.currentIndex = 3
			},
			randomCoding() {
				//创建26个字母数组
				var arr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
					'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
				];
				var idvalue = '';
				let n = 2; //这个值可以改变的，对应的生成多少个字母，根据自己需求所改
				for (var i = 0; i < n; i++) {
					idvalue += arr[Math.floor(Math.random() * 26)];
				}
				return idvalue;
			},

			shareInfo(type) {


				if (this.checkedList.length == 0) return this.$refs.uToast.show({
					type: "error",
					message: "请选择房源"
				})
				var loadding = uni.showLoading({
					title: '加载中'
				})
				var imgList = []
				this.pageList.map((item, index) => {
					this.checkedList.map((checkedtItem, checkedIndex) => {
						if (item.id == checkedtItem) {
							if (item.mediaUrl) {
								imgList.push(item.mediaUrl)
							}
						}
					})
				})

				let uid = uni.getStorageSync("uid")
				let uname = uni.getStorageSync("uname")
				let phone = uni.getStorageSync("phone")
				let codestr = new Date().valueOf() + ""
				const defaultShareImg =
					"https://dabinhouse-1320826375.cos.ap-shanghai.myqcloud.com/folder/%E6%9A%82%E6%97%A0%E5%9B%BE%E7%89%87.png"
				let shareUrl = encodeURI(this.$h5Url + '?ids=' + this.checkedList.join(',') + '&checkbox=' + this
					.checkboxValue1
					.join(',') + '&uid=' + uid + '&uname=' + uname + '&phone=' + phone + '&time=' + this
					.getNowFormatDate() + "&code=" + this.randomCoding() + codestr.substr(codestr.length - 4, codestr
						.length))
				console.log(shareUrl);
				let base64Url = btoa(unescape(encodeURIComponent(shareUrl)));

				var that = this
				uni.share({
					provider: "weixin",
					scene: type,
					type: 0,
					href: shareUrl, //这里写打开app的urlschemes
					// title: `编号${this.randomCoding() + codestr.substr(codestr.length - 4, codestr.length)}为您推荐了${this.checkedList.length}套好房`,
					title: `(编号:${this.randomCoding() + codestr.substr(codestr.length - 4, codestr.length)}）租房找大宾`,
					summary: `管家为您推荐了${this.checkedList.length}套好房, 快来看看吧`,
					imageUrl: imgList[0] || defaultShareImg,
					success: function(res) {
						console.log("success:" + JSON.stringify(res));
						that.showShare = false;
						uni.hideLoading(loadding);
						that.loadmore();
						that.$refs.uToast.show({
							type: "success",
							message: '分享成功'
						})
						that.checkedList = []
						that.fliterChecked = []
						that.checkboxValue1 = []

					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err));
						that.showShare = false;
						that.loadmore();
						that.$refs.uToast.show({
							type: "error",
							message: '分享失败'
						})

						that.fliterChecked = []
						that.checkboxValue1 = []
						that.checkedList = []

					}
				});
				return
				const res = getQrcode(base64Url)

				if (res.data.code == 200) {
					this.qrimgUrl = res.data.data;
					this.showQrTips = true
				} else {
					this.showQrTips = true;
					this.qrimgUrl = '../static/default/qrError.jpeg'
				}

			},

			saveImage() {
				const qrImageNetAddr = this.qrimgUrl;
				// 先下载二维码
				uni.downloadFile({
					url: qrImageNetAddr,
					success: (res) => {
						const that = this
						if (res.statusCode === 200) {
							// 关闭loading
							//  uni.hideLoading()
							// 保存视频到手机相册
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									// 成功提示

									uni.showToast({
										title: '保存成功',
										icon: 'none'
									})
									//this.showQrTips=false;

								}
							})
						}

					}
				})
			},



			//获取当前日期函数
			getNowFormatDate() {
				let date = new Date(),
					obj = {
						year: date.getFullYear(), //获取完整的年份(4位)
						month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
						strDate: date.getDate(), // 获取当前日(1-31)
						hour: date.getHours(), //获取当前小时(0 ~ 23)
						minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
						second: date.getSeconds() //获取当前秒数(0 ~ 59)
					}
				Object.keys(obj).forEach(key => {
					if (obj[key] < 10) obj[key] = `0${obj[key]}`
					// console.log(obj[key])
				})

				return `${obj.year}-${obj.month}-${obj.strDate}-${obj.hour}:${obj.minute}:${obj.second}`
			},
			changeChecked(id) {
				if (this.checkedList.indexOf(id) != -1) {
					this.checkedList.map((item, index) => {
						if (item == id) {
							this.checkedList.splice(index, 1)
						}
					})
				} else {
					this.checkedList.push(id)
				}
			},
			closeShare() {

				this.checkedList = []
				this.pageList = [];
				this.showShare = false
				this.loadmore();


			},
			closeQrCode() {
				this.showQrTips = false;
			},
			checkboxChange(data) {
				console.log(data);
			},
			checkboxChange1(n) {
				this.fliterChecked = n

				// console.log('change', n);
			},
			clearVUEX() {
				this.otherInfo = {
					lodgeData: "",
					typeData: "",
					specialData: [],
					statusData: "",
					otherData: "",
				}
				this.$store.commit('clearSearchForm');
				this.$store.commit('clearSearchRange')
			},
			resultSerch() {
				this.showSearch = false
				this.isSearchViewIsShow = false
				this.status = 'loading'
				this.ifFunState();
				this.getSwriper()
				for (var key in this.pageParams) {
					this.pageParams[key] = null
				}
				this.pageParams.houseLabels = []
				this.pageParams.pageNum = 1;
				this.pageParams.pageSize = 10
				console.log(this.pageParams);

				this.pageList = [];
				this.loadmore();
			},
			resultValue() {
				this.showRent = false
				this.status = 'loading'
				this.ifFunState();
				this.getSwriper()
				this.$store.commit('clearSearchRange')
				for (var key in this.pageParams) {
					this.pageParams[key] = null
				}
				this.pageParams.houseLabels = []
				this.pageParams.pageNum = 1;
				this.pageParams.pageSize = 10
				console.log(this.pageParams);

				this.pageList = [];
				this.loadmore();
			},
			computedEl(el, callback) {
				const query = uni.createSelectorQuery().in(this);
				query.select(el).boundingClientRect(data => {
					callback(data)
				}).exec();
			},

			disabledScroll() {
				return
			},
			ifFunState() {
				var state = uni.getStorageSync('useState')
				if (state != '2') {
					this.showTips = true
					this.completeInfoState = state
				} else {
					this.showTips = false
				}

				this.getUserState()
			},
			async getUserState() {
				const res = await getUserInfo();
				if (res.data.code != 200) return this.$refs.uToast.show({
					type: "error",
					message: res.data.msg
				})

				var state = res.data.data.completeInfoState
				// console.log(res);
				uni.setStorageSync('useState', state)
				uni.setStorageSync('uid', res.data.data.id)
				uni.setStorageSync('uname', res.data.data.nickName)
				if (state == '0' || state == '1') {
					this.showTips = true;
					this.completeInfoState = state
				} else if (state == '2') {
					this.showTips = false;
					this.showPopup = false;
				}
			},

			tounchNameMethod(name) {
				this.pageParams.pageNum = 1;
				this.pageList = [];
				this.status = 'loading'
				this.pageParams.keyWords = name;

				this.isSearchViewIsShow = false
				this.loadmore()
			},

			cloneMoney() {
				this.showSearch = false;
				this.showRent = false;
				this.currentIndex = 0
			},
			changeSearch(searchObj) {
				this.status = "loading"

				this.pageParams.keyWords = searchObj.communityName, // 小区名称
					this.pageParams.ventricleNumber = searchObj.ventricleNumber, // 门牌号
					this.pageParams.buildingNumber = searchObj.buildingNumber, // 楼栋号
					this.pageParams.pageNum = 1
				this.pageList = [];

				this.loadmore();
				this.showSearch = false;
				this.showRent = false;
				this.currentIndex = 0
				// 重置
				// this.$refs.rentResult.rentReset()
			},
			changeRent(rentObj) {
				this.status = "loading"
				if (rentObj.start != "" || rentObj.end != "" || rentObj.sort != "") {
					this.pageParams.orderByColumn = "rental"
				}
				this.pageParams.rentalBegin = rentObj.start || null, // 起始租金
					this.pageParams.rentalEnd = rentObj.end || null, // 止租金
					this.pageParams.isAsc = rentObj.sort || null,
					this.pageParams.pageNum = 1
				this.pageList = []
				this.loadmore();
				this.showSearch = false;
				this.showRent = false;
				this.currentIndex = 0;
				// this.pageParams.orderByColumn = null
				// 重置
				// this.$refs.rentResult.rentReset()
			},
			async loadmore() {
				if (this.status == 'nomore') return

				let loadding = uni.showLoading({
					title: '加载中……'
				})
				const {
					pageNum,
					pageSize,
					orderByColumn,
					keyWords, //关键字
					rentalBegin, // 起始租金
					rentalEnd, // 止租金
					rentalType, // 出租类型 0 合租 1 整租 
					houseType, // 几室直接传资
					houseLabels,
					rentState,
					isAsc,
					communityName,
					ventricleNumber,
					buildingNumber,
					otherData
				} = this.pageParams

				const res = await homeListPage({
					pageNum,
					pageSize,
					orderByColumn,
					keyWords, //关键字
					rentalBegin: parseInt(rentalBegin), // 起始租金
					rentalEnd: parseInt(rentalEnd), // 止租金
					rentalType, // 出租类型 0 合租 1 整租 
					houseType, // 几室直接传资
					houseLabels,
					isAsc,
					rentState,
					communityName,
					ventricleNumber,
					buildingNumber,
					otherData //其他选项
				})
				// console.log(res, 1111111111111);
				if (res.data.code == 403) return uni.redirectTo({
					url: '/pages/login/login',
					success() {
						uni.showToast({
							title: '登录身份异常，请联系管理员!',
							icon: 'none'
						})
						// uni.hideLoading(loadding)
					}
				})
				if (res.data.code != 200) {
					uni.hideLoading(loadding)
					this.$refs.uToast.show({
						type: "error",
						message: '刷新失败'
					})
					uni.stopPullDownRefresh();
					return
				}


				this.pageList.push(...res.data.rows);
				if (this.pageList.length == res.data.total) {
					console.log('===');
					this.status = 'nomore'
				} else {
					this.pageParams.pageNum += 1

				}
				// console.log(this.pageList, 456)
				uni.hideLoading(loadding)
				uni.stopPullDownRefresh();

			},

			//  
			async getSwriper() {
				const res = await getImgList();
				if (res.data.code != 200) return this.$refs.uToast.show({
					type: "error",
					message: res.data.msg
				})
				this.imgList = res.data.data
				this.loadingSwiper = false

			},

			// 多选处理 参数 1点击项  参数2 需要更新的数据   (备注 二次点击即为取消)
			mulHandle(item, data = []) {
				var index = data.indexOf(item)
				if (index !== -1) {
					data.splice(index, 1)
				} else {
					data.push(item)
				}
			},
			specialTagClick(item) {
				this.mulHandle(item, this.otherInfo.specialData)
			},
			publishEject() {
				this.eject = !this.eject
			},
			publish() {
				uni.navigateTo({
					url: '../home/addhouse/option'
				})
			},
			myPublish() {
				uni.navigateTo({
					url: '../house/index'
				})
			},
			gotoSearch() {
				this.isSearchViewIsShow = true


			},
			tabclick(e) {
				// this.status = 'loading'
				switch (e.name) {
					case '搜索':
						//this.isSearchViewIsShow = true
						this.showSearch = true;
						this.showRent = false;
						this.otherRent = false
						this.showShare = false
						break;
					case '租金':
						this.showRent = true
						this.showShare = false
						break;
					case '其他':
						this.otherRent = true;
						this.showShare = false
						break;
					case '多选':
						this.checkedList = []
						this.showShare = !this.showShare
						break;
					default:
						break;
				}
			},
			// 跳转完善信息
			toPerfectInfo() {
				uni.navigateTo({
					url: '/pages/home/toPerfectInfo1'
				})
			},

			scrolltolower() {
				this.loadmore()
			},

			gotoDetails(item) {
				uni.setStorageSync('id', item.id)
				uni.navigateTo({
					url: '/pages/home/details?id=' + item.id
				})
			},
			gotoCollect() {
				uni.navigateTo({
					url: '/pages/home/collect'
				})
			},
			// 租金操作


			// 其他 
			otherReset() {
				this.otherInfo = {
					lodgeData: "",
					typeData: "",
					specialData: [],
					statusData: "",
					otherData: "",
				}
				this.status = "loading"
				this.ifFunState();
				this.getSwriper()
				for (var key in this.pageParams) {
					this.pageParams[key] = null
				}
				this.pageParams.houseLabels = []
				this.pageParams.pageNum = 1;
				this.pageParams.pageSize = 10
				this.pageList = [];
				this.loadmore();

				this.otherRent = false
			},
			otherSubmit() {

				this.status = 'loading'
				this.pageParams.rentalType = this.otherInfo.lodgeData;
				this.pageParams.houseType = this.otherInfo.typeData;
				if (this.otherInfo.specialData.length != 0) {
					this.otherInfo.specialData.map((item) => {
						var obj = {
							labelName: item
						}
						this.pageParams.houseLabels.push(obj)
					})
				}

				this.pageParams.otherData = this.otherInfo.otherData;
				this.pageParams.rentState = this.otherInfo.statusData;
				this.pageList = [];
				this.pageParams.pageNum = 1

				this.loadmore()
				this.otherRent = false;
				// this.pageParams.houseLabels = []
			},
			async queryVersion() {
				const res = await getServerAppVersion();

				const url = res.data.data.downUrl;
				var appServerAPIVersion = res.data.data.versionNo;
				//当前app版本号
				var currappVersion = plus.runtime.version;
				//var currappVersion='1.0.29';
				var v1 = appServerAPIVersion.split(".")[2];
				var v2 = currappVersion.split(".")[2];
				if (v1 > v2) {
					//蒙版提示更新不让操作
					uni.showModal({
						title: '更新提示',
						content: '发现新版本，需要更新才能继续使用！',
						showCancel: false,
						buttonText: '去下载',
						success: function(res) {
							plus.runtime.openURL(url)
						}
					});
				}
			},
			//喜讯通知
			async getLast() {
				const res = await getLast()
				this.data = res.data.data
			},

		}
	}
</script>

<style lang="scss" scoped>
	@import "@/styles/global.scss";
	@import "@/styles/index.scss";



	.u-nav-slot {
		margin-right: 30rpx;
	}

	.banner_box {
		width: 100%;
		// height: 225rpx;
		margin-top: 30rpx;
		box-sizing: border-box;
	}

	.text_row {
		@include flexBetween;
		margin-top: 40rpx;
		font-size: 30rpx;

		text {
			font-weight: bold;
			color: $theme;
			font-size: 40rpx;
		}
	}

	.popup_box {
		padding: 40rpx;
		@include flexCenter;
		flex-direction: column;
		box-sizing: border-box;

		.title {
			font-size: 50rpx;
			font-weight: bold;
			line-height: 2;
		}

		.button_box {
			margin-top: 60rpx;
		}
	}

	.padding {
		padding: 30rpx;
	}

	.header_img {
		width: 100%;
		height: 300rpx;
		margin-top: 20rpx;
	}

	.show_tips {
		width: 400rpx;
		padding: 40rpx;
		font-size: 32rpx;
		background-color: #fff;
		color: rgba(16, 16, 16, 1);
		border-radius: 10rpx;

		.btn {
			margin-top: 40rpx;
		}
	}

	.eject {
		padding: 20rpx;
		width: 30%;
		color: white;
		background-color: #454343;
		position: absolute;
		// top: 130rpx;
		float: right;
		// right: 15rpx;
		border-radius: 10rpx;
		z-index: 99;
		@include textOverflow;
		// position: relative;
	}



	.rent_wrapper {
		// width: 80%;
		padding: 30rpx;
		margin-top: 30rpx;

		.content {
			max-height: 400rpx;

			.input {

				display: flex;
				justify-content: flex-start;
				align-items: center;
				padding: 10rpx 0;


				.input_i {
					width: 200rpx;
					height: 70rpx;

				}
			}

			.tag_wrp {
				display: flex;
				flex-wrap: wrap;

				.item {
					flex-basis: 100%;
					max-width: calc(100% / 3);
					flex-grow: 1;

					.label {
						width: 80%;
						height: 50rpx;
						line-height: 50rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						font-size: 25rpx;
						margin: 0 10%;
						color: rgb(102, 102, 102);
						background: rgba(115, 110, 110, 0.07);
						margin-top: 20rpx;
						@include textOverflow;
					}
				}
			}



		}

		.btn_wrp {
			// padding: 20rpx;
			display: flex;
			justify-content: space-around;
			align-items: center;
			margin: 20rpx 0;
			height: 100rpx;

			.btn {
				margin: 0 10rpx;
				flex: 1;
			}
		}

		.activ_change_color {
			background-color: rgb(240, 90, 35) !important;
			color: #fff !important;
		}
	}

	.tabs_view {
		position: sticky;
		top: 75px;
		z-index: 99;
		background-color: #fff;
		width: 100%;
		padding: 10rpx 0;
	}

	.wrapper {
		padding: 40rpx 20rpx;

		.list_wrapper {
			.sub_nav {
				width: 100%;
				display: flex;
				justify-content: space-around;
				align-items: center;
				padding: 10rpx 0;

				.sub_nav_wrp {
					display: flex;
					align-items: center;
				}
			}
		}
	}



	.fliter_state ::v-deep .u-slide-right-enter-active {
		width: 80% !important;
	}

	.fliter_state ::v-deep .u-slide-right-enter-to {
		width: 80% !important;
	}

	.fliter_state ::v-deep .u-transition {
		width: 80% !important;
	}

	.lable_title {
		font-size: 30rpx;
		color: #000;
		font-weight: bold;
		margin-top: 20rpx;
	}
</style>